package com.coolbi.security.dao.impl;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;

import com.coolbi.security.dao.RoleToGroupDao;
import com.coolbi.security.entity.RoleToGroup;
import com.coolbi.security.entity.Roles;
import com.coolbi.security.entity.UserGroup;
import com.coolbi.security.mapper.RoleToGroupMapper;

public class RoleToGroupDaoImpl implements RoleToGroupDao {

	@Autowired
	private RoleToGroupMapper roleToGroupMapper;
	public void setRoleToGroupMapper(RoleToGroupMapper roleToGroupMapper) {
		this.roleToGroupMapper = roleToGroupMapper;
	}
	
	@Override
	public List<RoleToGroup> find(Map<String, Object> parameter) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<RoleToGroup> find(Map<String, Object> parameter, int offset,
			int limit) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public int count(Map<String, Object> parameter) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public List<RoleToGroup> search(String keyword, int offset, int limit) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public int countByKeyword(String keyword) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public RoleToGroup save(RoleToGroup obj) {
		roleToGroupMapper.save(obj);
		return obj;
	}

	@Override
	public int update(RoleToGroup obj) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int delete(long id) {
		return roleToGroupMapper.delete(id);
	}

	@Override
	public RoleToGroup get(long id) {
		return null;
	}

	@Override
	public List<RoleToGroup> list() {
		return null;
	}

	@Override
	public List<RoleToGroup> list(int offset, int limit) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public int count() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public List<Roles> findRoleByGroupId(long id) {
		return roleToGroupMapper.findRoleByGroupId(id);
	}

	@Override
	public List<UserGroup> findGroupByRoleId(long id) {
		return roleToGroupMapper.findGroupByRoleId(id);
	}

	@Override
	public int deleteByGroupId(long id) {
		return roleToGroupMapper.deleteByGroupId(id);
	}

	@Override
	public List<Roles> findParentRoleByGroupId(long id) {
		return roleToGroupMapper.findParentRoleByGroupId(id);
	}

	@Override
	public List<Long> findByRolesAndGroupId(Long[] roleArray, Long groupId) {
		Map<String, Object> parameter = new HashMap<String, Object>();
		parameter.put("groupId", groupId);
		parameter.put("roleId", Arrays.asList(roleArray));
		return roleToGroupMapper.findByRolesAndGroupId(parameter);
	}

	@Override
	public int deleteByRoleIds(Long[] roleArray, Long groupId) {
		Map<String, Object> parameter = new HashMap<String, Object>();
		parameter.put("groupId", groupId);
		parameter.put("roleId", Arrays.asList(roleArray));
		return roleToGroupMapper.deleteByRoleIds(parameter);
	}
}
